package com.bw.util;

public class PageUtil {

	
	private String page;
	
	public static int nowpage;
	
	private int nextpage;
	
	private int count;
	
	private int prevpage;
	
	private int lastpage;
	
	private int pagesize;
	
	private int pageindex;
	
	
	public int getPageindex() {
		return pageindex;
	}
	
	public String getPage() {
		return page;
	}

	public int getNowpage() {
		return nowpage;
	}

	public int getNextpage() {
		return nextpage;
	}

	public int getCount() {
		return count;
	}

	public int getPrevpage() {
		return prevpage;
	}
	
	public int getLastpage() {
		return lastpage;
	}

	public int getPagesize() {
		return pagesize;
	}

	public PageUtil(String page, int count, int pagesize) {
		this.page = page;
		this.count = count;
		this.pagesize = pagesize;
		initnowpage();
		initprevpage();
		initlastpage();
		initnextpage();
		initindex();
	}	

	//���嵱ǰҳ
	private void initnowpage(){
		page= page==null?"1":page;
		nowpage=Integer.parseInt(page);
	}
	
	//������һҳ
	private void initprevpage(){
		if(nowpage == 1){
			prevpage=nowpage;	
		}else{
			 prevpage=nowpage-1;
		}	
	}
	
	//����ĩҳ
	private void initlastpage(){
		lastpage=(int)Math.ceil((double)count/pagesize);		
	}
	
	//������һҳ
	private void initnextpage(){
		if(nowpage==lastpage){
			nextpage=lastpage;
		}else{
			nextpage=nowpage+1;
		}
	}
	private void initindex(){
		pageindex=(nowpage-1)*pagesize;
	}
}
